# -*- coding: utf-8 -*-
'''
@author: Hugo
@file: crawl.py
@time: 2021/8/29 16:24
'''
import requests

def ff():
    try:
        headers = {
            'user-agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.77 Safari/537.36',
            'referer':'https://danjuanapp.com/funding/200015?channel=1300100141'
        }
        url = 'https://danjuanapp.com/djapi/fund/nav-growth/200015?day=30'
        res = requests.get(url,headers = headers)
        data = res.json()
        if data.get('data'):
            result = data.get('data').get('fund_nav_growth')
            times = []
            zf = []
            for i in result:
                time = i.get('date')
                date = time.replace(time.split('-')[0]+'-','')
                z = i.get('gr_per')
                times.append(time)
                zf.append(z)
            return {'time':times,'price':zf}
    except Exception as e:
        print(e)
        return None


print(ff())